package com.sixfoot.service;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.sixfoot.dao.ResourceRepository;
import com.sixfoot.domain.Resource;
import com.sixfoot.facade.resource.ResourceDto;
import com.sixfoot.facade.resource.ResourceInputArgs;
import com.sixfoot.foundation.mapping.service.DtoPagingService;
import com.sixfoot.hrv.codec.protobuf.ResourceProto;

@Service
@Transactional
public class ResourceService extends DtoPagingService<Resource, ResourceDto, ResourceInputArgs, String> {

	public List<Resource> loadFirsts() {
		List<Resource> resources = ((ResourceRepository) super.getRepository()).findByParent(null);
		return resources;
	}
	
	public void loadChilds(String id) {
		Resource resource = ((ResourceRepository) super.getRepository()).findOne(id);
		if (resource != null) {
			ResourceProto.Resource.Builder resourceRespBuidler = ResourceProto.Resource.newBuilder();
			resourceRespBuidler.setId(resource.getId());
			resourceRespBuidler.setName(resource.getName());
			resourceRespBuidler.setSeq(resource.getSeq());
		}
		return;
	}
	
	
}
